Many of us debug by trial in error.
Does this process seem familiar?
Begin:
That last change didn't work
So I'll try this different change
That didn't work so I'll try this new change
That didn't work so I'll try this new change
Loop
THAT, my aspiring computer coding jockeys, is the definition of hacking.
It can be VERY satisfying, when it works... when it doesn't work, it can be monumentally frustrating.
Towards that end, I need to emphasize the importance of NOT HACKING your code...
That means taking a step back, smelling the coffee (A grande non-fat white chocolate mocha with just a bit of whipped cream for me!) and actually analyzing your code, finding out what is really wrong and addressing that problem...
To wit:
There are three pretty glaring bugs in THIS code.
Run the code a few times and identify those three bugs by inspection.
Let's discuss
Now go find the locations in the code where the bugs occur.
Now actually step through the code and reproduce in your mind the behavior that is occurring on the screen. SOMEWHERE in that process you'll find the error... you will, honest, trust me... they're there, waiting for you
Now let's go back to our own brick-in-the-wall programs and see if we can get those knocked out today